package cn.net.xyan.easy.gwt.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestException;
import org.fusesource.restygwt.client.Dispatcher;
import org.fusesource.restygwt.client.Method;


/**
 * Created by zarra on 16/3/8.
 */
public class EZGwtDispatcher implements Dispatcher {

    public static final EZGwtDispatcher INSTANCE = new EZGwtDispatcher();

    @Override
    public Request send(Method method, RequestBuilder requestBuilder) throws RequestException {

        requestBuilder.setHeader("X-CSRF-TOKEN", EZGwt.CSRFToken());

        return requestBuilder.send();
    }
}
